Warning: mkdir(): No space left on device in /var/www/tg-me/post.php on line 37

Warning: file_put_contents(aCache/aDaily/post/golangtests/--): Failed to open stream: No such file or directory in /var/www/tg-me/post.php on line 50
Go tests | Telegram Webview: golangtests/777 -
Telegram Group & Telegram Channel
🧠 Хитрая задача на Go (v1.22+) — алгоритмы, циклы и подвох в логике

📌 Задача: "Подряд идущие квадраты"

Дано: массив из N положительных целых чисел []int, например:


[]int{1, 4, 9, 16, 25, 36, 50, 64, 81}


Нужно найти максимальную длину подмассива, где все элементы — квадраты подряд идущих натуральных чисел.

Например, [4, 9, 16, 25] — это квадраты 2², 3², 4², 5² → длина = 4
[50, 64] — не подходят, так как 50 не является точным квадратом.

🎯 Формат функции:


func MaxConsecutiveSquares(nums []int) int


Пример:


input := []int{1, 4, 9, 16, 25, 36, 50, 64, 81}
fmt.Println(MaxConsecutiveSquares(input)) // 👉 6


🧩 Подвох:

- Часто пытаются сравнивать разности или применять хэшмапы — но это ошибка
- Нужно восстановить корни чисел (`sqrt`) и убедиться, что они натуральные и идут подряд
- Важно использовать math.Sqrt и быть осторожным с плавающей точкой (`float64`)
- Также важно не выходить за границы slice

💡 Подсказка:

```go
import "math"

func isSquare(n int) (int, bool) {
root := int(math.Sqrt(float64(n)))
return root, root*root == n
}
```

🛠 **Что проверяет задача:**

• Умение работать с нецелыми корнями
• Алгоритмы "двойного указателя" (две границы окна)
• Понимание строгой проверки на натуральные числа
• Внимание к float64-погрешности и типам



tg-me.com/golangtests/777
Create:
Last Update:

🧠 Хитрая задача на Go (v1.22+) — алгоритмы, циклы и подвох в логике

📌 Задача: "Подряд идущие квадраты"

Дано: массив из N положительных целых чисел []int, например:


[]int{1, 4, 9, 16, 25, 36, 50, 64, 81}


Нужно найти максимальную длину подмассива, где все элементы — квадраты подряд идущих натуральных чисел.

Например, [4, 9, 16, 25] — это квадраты 2², 3², 4², 5² → длина = 4
[50, 64] — не подходят, так как 50 не является точным квадратом.

🎯 Формат функции:


func MaxConsecutiveSquares(nums []int) int


Пример:


input := []int{1, 4, 9, 16, 25, 36, 50, 64, 81}
fmt.Println(MaxConsecutiveSquares(input)) // 👉 6


🧩 Подвох:

- Часто пытаются сравнивать разности или применять хэшмапы — но это ошибка
- Нужно восстановить корни чисел (`sqrt`) и убедиться, что они натуральные и идут подряд
- Важно использовать math.Sqrt и быть осторожным с плавающей точкой (`float64`)
- Также важно не выходить за границы slice

💡 Подсказка:

```go
import "math"

func isSquare(n int) (int, bool) {
root := int(math.Sqrt(float64(n)))
return root, root*root == n
}
```

🛠 **Что проверяет задача:**

• Умение работать с нецелыми корнями
• Алгоритмы "двойного указателя" (две границы окна)
• Понимание строгой проверки на натуральные числа
• Внимание к float64-погрешности и типам

BY Go tests


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/golangtests/777

View MORE
Open in Telegram


Go tests Telegram | DID YOU KNOW?

Date: |

For some time, Mr. Durov and a few dozen staffers had no fixed headquarters, but rather traveled the world, setting up shop in one city after another, he told the Journal in 2016. The company now has its operational base in Dubai, though it says it doesn’t keep servers there.Mr. Durov maintains a yearslong friendship from his VK days with actor and tech investor Jared Leto, with whom he shares an ascetic lifestyle that eschews meat and alcohol.

How To Find Channels On Telegram?

There are multiple ways you can search for Telegram channels. One of the methods is really logical and you should all know it by now. We’re talking about using Telegram’s native search option. Make sure to download Telegram from the official website or update it to the latest version, using this link. Once you’ve installed Telegram, you can simply open the app and use the search bar. Tap on the magnifier icon and search for a channel that might interest you (e.g. Marvel comics). Even though this is the easiest method for searching Telegram channels, it isn’t the best one. This method is limited because it shows you only a couple of results per search.

Go tests from nl


Telegram Go tests
FROM USA